package com.imooc.sidney.player;

import java.util.List;

/**
 * @author Sidney 2018/6/4.
 */
public class PlayList {
    private String playListName;
    private List<Song> musicList;

    public PlayList() {
    }

    public PlayList(String playListName, List<Song> musicList) {
        this.playListName = playListName;
        this.musicList = musicList;
    }

    public String getPlayListName() {
        return playListName;
    }

    public void setPlayListName(String playListName) {
        this.playListName = playListName;
    }

    public List<Song> getMusicList() {
        return musicList;
    }

    public void setMusicList(List<Song> musicList) {
        this.musicList = musicList;
    }

    public void addToPlayList(Song song){
        musicList.add(song);
    }
    public void displayAllSong(){
        for (Song song : musicList) {
            System.out.println(song.toString());
        }
    }
    public Song searchSongById(String id){
        Song result = new Song();
        for (Song song : musicList) {
            if (song.getSongId().equals(id)) {
                result = song;
            }
        }
        return result;
    }
    public Song searchSongByName(String name){
        Song result = new Song();
        for (Song song : musicList) {
            if (song.getSongName().equals(name)) {
                result = song;
            }
        }
        return result;
    }
    public void updateSong(Song song){
        for (Song song1 : musicList) {
            if (song1.getSongId().equals(song.getSongId())) {
                song1.setSongName(song.getSongName());
                song1.setSinger(song.getSinger());
            }
        }
    }

    public void deleteSong(String id){
        musicList.removeIf(next -> next.getSongId().equals(id));
    }

    public void exportPlayList(){

    }

}
